package xin.marcher.module.scheduling.job.inventory;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.inventory.api.InventoryServiceApi;

/**
 *
 */
@Slf4j
@Component
public class BucketOperateJobHandler {

    @DubboReference(version = "1.0.0")
    private InventoryServiceApi inventoryService;

    @XxlJob("processBucketOperate")
    public void processBucketOperate() {
        XxlJobHelper.log("process bucket operate job starting...");
        JsonResult result = inventoryService.processBucketOperate();
        XxlJobHelper.log("process bucket operate job end, result: {}", result);
    }

    @XxlJob("bucketOperateFinishedClear")
    public void bucketOperateFinishedClear() {
        XxlJobHelper.log("bucket operate finished clear job starting...");
        JsonResult result = inventoryService.bucketOperateFinishedClear();
        XxlJobHelper.log("bucket operate finished clear job end, result: {}", result);
    }

    @XxlJob("calculateOfflineThreshold")
    public void calculateOfflineThreshold() {
        XxlJobHelper.log("calculate offline threshold job starting...");
        JsonResult result = inventoryService.calculateOfflineThreshold();
        XxlJobHelper.log("calculate offline threshold job end, result: {}", result);
    }
}
